package malus.shaofeng.com.beiwomusic.model;

import android.text.TextUtils;

import org.json.JSONObject;
import org.w3c.dom.Text;

/**
 * 有登录的用户
 */
public class LoginUser{
    private String nickname;
    private String face_uri;
    private long user_id;
    private int sex;
    private String account;
    private int modify_face;
    private String province;
    private int city_id;
    private String city;
    private int author;
    private String password;

    /**
     * 解析服务器的json数据
     * @param object
     */
    public void parseJSON(JSONObject object){
        this.user_id=object.optInt("user_id");
        this.account=object.optString("account");
        this.password=object.optString("password");
        this.nickname=object.optString("nickname");
        this.face_uri=object.optString("face_uri");
        this.modify_face=object.optInt("modify_face");
        this.sex=object.optInt("sex");
        this.province=object.optString("province");
        this.city_id=object.optInt("city_id");
        this.city=object.optString("city");
        this.author=object.optInt("author");
    }

    /**
     * 解析Weibo的json数据
     * @param object
     */
    public void parseWeiboJSON(JSONObject object){
        String location=object.optString("location");
        if(!TextUtils.isEmpty(location)){
            String[] split = location.split(" ");
            if(!TextUtils.isEmpty(split[0])){
                this.province=split[0];
                if(!TextUtils.isEmpty(split[1])){
                    this.city=split[1];
                }
            }
        }
        this.nickname=object.optString("name");
        this.face_uri=object.optString("profile_image_url");
        this.user_id=object.optInt("id");
        this.account=object.optString("name");
        this.city_id=object.optInt("city");
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getFace_uri() {
        return face_uri;
    }

    public void setFace_uri(String face_uri) {
        this.face_uri = face_uri;
    }

    public long getUser_id() {
        return user_id;
    }

    public void setUser_id(long user_id) {
        this.user_id = user_id;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public int getModify_face() {
        return modify_face;
    }

    public void setModify_face(int modify_face) {
        this.modify_face = modify_face;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public int getCity_id() {
        return city_id;
    }

    public void setCity_id(int city_id) {
        this.city_id = city_id;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public int getAuthor() {
        return author;
    }

    public void setAuthor(int author) {
        this.author = author;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
